package com.csw.android.ffmpegtest.app

import com.csw.android.dev_utils.ex.FileEx.generateDirectory
import com.csw.android.dev_utils.utils.DateUtils

object Config {
    //文件存储根路径，优先存储在存储卡根目录
    val ROOT_PATH: String

    init {
        val internalFile = MyApplication.instance.filesDir
        val externalFile = MyApplication.instance.getExternalFilesDir("")
        if (externalFile != null) {
            ROOT_PATH = externalFile.absolutePath
        } else {
            ROOT_PATH = internalFile.absolutePath
        }
    }

    object Section201 {
        val DIR = "Section201"

        //录音文件路径
        val WAV_PATH: String

        init {
            WAV_PATH = "$ROOT_PATH/$DIR/wav"
            WAV_PATH.generateDirectory()
        }

        /**
         * 根据文件名称获取图片路径
         */
        fun getWavPath(fileName: String = DateUtils.getCurrDateString()): String {
            return "$WAV_PATH/$fileName.wav"
        }
    }

    object Section301 {
        val DIR = "Section301"

        //拍照路径
        val PICTURE_PATH: String

        //录像
        val VIDEO_PATH: String

        init {
            PICTURE_PATH = "$ROOT_PATH/$DIR/picture"
            PICTURE_PATH.generateDirectory()
            VIDEO_PATH = "$ROOT_PATH/$DIR/video"
            VIDEO_PATH.generateDirectory()
        }

        /**
         * 根据文件名称获取图片路径
         */
        fun getPicturePath(fileName: String = DateUtils.getCurrDateString()): String {
            return "$PICTURE_PATH/$fileName.jpg"
        }


        /**
         * 根据文件名称获取图片路径
         */
        fun getVideoPath(fileName: String = DateUtils.getCurrDateString()): String {
            return "$VIDEO_PATH/$fileName.mp4"
        }
    }


    object Section701 {
        val DIR = "Section701"

        //录音文件路径
        val AAC_PATH: String

        init {
            AAC_PATH = "$ROOT_PATH/$DIR/aac"
            AAC_PATH.generateDirectory()
        }

        /**
         * 根据文件名称获取图片路径
         */
        fun getAacPath(fileName: String = DateUtils.getCurrDateString()): String {
            return "$AAC_PATH/$fileName.aac"
        }
    }
}